import qr from 'qr-image';
import log from '../../../log';
import * as util from '../../../util';
import backupDatabase from '../../../schedules/BackupDatabase';

export function createQRCode(query) {
    return util.resolve().then(() => {
        log.info('createQRCode params----', query);
        const {str, type = 'png', size = 6, } = query;
        if (!str) {
            throw 'str没有传参数';
        }
        return qr.image(str, {type, size });
    }).catch(err => {
        log.error('createQRCode is err----', err);
        throw err;
    });
}

export function backupDB(query) {
    return util.resolve().then(() => {
        log.info('backupDB params----', query);
        return backupDatabase();
    }).catch(err => {
        log.error('backupDB is err----', err);
        throw err;
    });
}
